package gov.child.dao;

import gov.child.dao.exception.EntityQueryException;
import gov.child.entities.po.EUser;
import gov.child.entities.vo.Page;
import org.jetbrains.annotations.NotNull;

import java.util.List;

/**
 * The interface User dao. --finish
 *
 * @author fzh
 * @since 2017 /9/10
 */
public interface UserDao extends Pageable {
    /**
     * 查找所有用户
     *
     * @return the list
     */
    default List findAll() {
        return findAll(Page.singlePage());
    }

    ;

    /**
     * 查找所有用户（分页）
     *
     * @param page the page
     * @return the list
     */
    List findAll(Page page);

    /**
     * 根据用户名和密码查找用户
     *
     * @return the e user
     * @throws EntityQueryException the entity query exception
     */
    EUser findByUsernameAndPassword(String username, String password) throws EntityQueryException;

    /**
     * 根据电话和密码查找用户
     *
     * @return the e user
     * @throws EntityQueryException the entity query exception
     */
    EUser findByPhoneAndPassword(String phone, String password) throws EntityQueryException;

    /**
     * 根据身份证号和密码查找用户
     *
     * @return the e user
     * @throws EntityQueryException the entity query exception
     */
    EUser findByIDNumAndPassword(String idNum, String password) throws EntityQueryException;

    /**
     * 创建用户
     *
     * @param user the user
     */
    void save(@NotNull EUser user);

    /**
     * 删除用户
     *
     * @param user the user
     */
    void delete(EUser user);

    /**
     * 更新用户信息
     *
     * @param user the user
     */
    void update(EUser user);

}
